home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
timeoday.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-06
|
909b
|
59 lines
/* BSDish gettimeofday() and settimeofday() calls */
/* also ftime(), which seems to be similar to gettimeofday() */
#include <types.h>
#include <time.h>
#include <unistd.h>
#ifdef __TURBOC__
#include <sys\timeb.h>
#else
#include <sys/timeb.h>
#endif
extern int _dst; /* in time.c */
extern long _timezone; /* in localtim.c */
int
gettimeofday( tv, tzp )
struct timeval *tv;
struct timezone *tzp;
{
struct timeb tp;
int r;
r = ftime(&tp);
if (r) return r;
if (tv) {
tv->tv_sec = tp.time;
tv->tv_usec = 0;
}
if (tzp) {
tzp->tz_minuteswest = tp.timezone;
tzp->tz_dsttime = tp.dstflag;
}
return 0;
}
int
settimeofday( tv, tzp )
struct timeval *tv;
struct timezone *tzp;
{
return stime(&tv->tv_sec);
}
int
ftime(tp)
struct timeb *tp;
{
long t = time((time_t *)0);
tp->time = t;
tp->millitm = 0;
tp->timezone = (int)(_timezone / 60);
tp->dstflag = (_dst) ? 1 : 0;
return 0;
}